//
//  BJUserManager.m
//  
//
//  Created by  on 2023/3/3.
//  Copyright © 2023 lishen. All rights reserved.
//

#import "BJUserManager.h"

@implementation BJUserManager

+ (BJUserManager *)sharedManager {
    static BJUserManager *manager = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        manager = [[self alloc] init];
        
    });
    return manager;
}

- (void)setUserToken:(NSString *)userToken{
    [[NSUserDefaults standardUserDefaults] setValue:userToken forKey:kUserTokenKey];
    [[NSUserDefaults standardUserDefaults]  synchronize];
}

- (NSString *)getUserToken{
    NSString *userTokenStr = [[NSUserDefaults standardUserDefaults] objectForKey:kUserTokenKey];
    return userTokenStr.length > 0 ? userTokenStr : @"";
}

- (void)setUseId:(NSString *)userId{
    [[NSUserDefaults standardUserDefaults] setValue:userId forKey:kUserIdKey];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

- (NSString *)getUserId{
    NSString *userId = [[NSUserDefaults standardUserDefaults] objectForKey:kUserIdKey];
    return userId.length > 0 ? userId : @"";
}



//是否登录了
- (BOOL)isLogin{
    return [self getUserId].length>0?YES:NO;
}

@end
